1//////////////////////////////////////////////////////////////////////
2// LibFile: nema_steppers.scad
3// Masks and models for NEMA stepper motors.
4// To use, add these lines to the top of your file:
5// ```
6// include <BOSL/constants.scad>
7// use <BOSL/nema_steppers.scad>
8// ```
9//////////////////////////////////////////////////////////////////////
10
11/*
12BSD 2-Clause License
13
14Copyright (c) 2017, Revar Desmera
15All rights reserved.
16
17Redistribution and use in source and binary forms, with or without
18modification, are permitted provided that the following conditions are met:
19
20* Redistributions of source code must retain the above copyright notice, this
21 list of conditions and the following disclaimer.
22
23* Redistributions in binary form must reproduce the above copyright notice,
24 this list of conditions and the following disclaimer in the documentation
25 and/or other materials provided with the distribution.
26
27THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
31FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
33SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37*/
38
39include <constants.scad>
40use <transforms.scad>
41use <shapes.scad>
42use <math.scad>
43use <compat.scad>
44
45
46// Section: Functions
47
48
49// Function: nema_motor_width()
50// Description: Gets width of NEMA motor of given standard size.
51// Arguments:
52// size = The standard NEMA motor size.
53function nema_motor_width(size) = lookup(size, [
54 [11.0, 28.2],
55 [14.0, 35.2],
56 [17.0, 42.3],
57 [23.0, 57.0],
58 [34.0, 86.0],
59 ]);
60
61
62// Function: nema_motor_plinth_height()
63// Description: Gets plinth height of NEMA motor of given standard size.
64// Arguments:
65// size = The standard NEMA motor size.
66function nema_motor_plinth_height(size) = lookup(size, [
67 [11.0, 1.5],
68 [14.0, 2.0],
69 [17.0, 2.0],
70 [23.0, 1.6],
71 [34.0, 2.03],
72 ]);
73
74
75// Function: nema_motor_plinth_diam()
76// Description: Gets plinth diameter of NEMA motor of given standard size.
77// Arguments:
78// size = The standard NEMA motor size.
79function nema_motor_plinth_diam(size) = lookup(size, [
80 [11.0, 22.0],
81 [14.0, 22.0],
82 [17.0, 22.0],
83 [23.0, 38.1],
84 [34.0, 73.0],
85 ]);
86
87
88// Function: nema_motor_screw_spacing()
89// Description: Gets screw spacing of NEMA motor of given standard size.
90// Arguments:
91// size = The standard NEMA motor size.
92function nema_motor_screw_spacing(size) = lookup(size, [
93 [11.0, 23.11],
94 [14.0, 26.0],
95 [17.0, 30.99],
96 [23.0, 47.14],
97 [34.0, 69.6],
98 ]);
99
100
101// Function: nema_motor_screw_size()
102// Description: Gets mount screw size of NEMA motor of given standard size.
103// Arguments:
104// size = The standard NEMA motor size.
105function nema_motor_screw_size(size) = lookup(size, [
106 [11.0, 2.6],
107 [14.0, 3.0],
108 [17.0, 3.0],
109 [23.0, 5.1],
110 [34.0, 5.5],
111 ]);
112
113
114// Function: nema_motor_screw_depth()
115// Description: Gets mount screwhole depth of NEMA motor of given standard size.
116// Arguments:
117// size = The standard NEMA motor size.
118function nema_motor_screw_depth(size) = lookup(size, [
119 [11.0, 3.0],
120 [14.0, 4.5],
121 [17.0, 4.5],
122 [23.0, 4.8],
123 [34.0, 9.0],
124 ]);
125
126
127// Section: Motor Models
128
129
130// Module: nema11_stepper()
131// Description: Creates a model of a NEMA 11 stepper motor.
132// Arguments:
133// h = Length of motor body. Default: 24mm
134// shaft = Shaft diameter. Default: 5mm
135// shaft_len = Length of shaft protruding out the top of the stepper motor. Default: 20mm
136// orient = Orientation of the stepper. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
137// align = Alignment of the stepper. Use the `V_` constants from `constants.scad`. Default: `V_DOWN`.
138// Example:
139// nema11_stepper();
140module nema11_stepper(h=24, shaft=5, shaft_len=20, orient=ORIENT_Z, align=V_DOWN)
141{
142 size = 11;
143 motor_width = nema_motor_width(size);
144 plinth_height = nema_motor_plinth_height(size);
145 plinth_diam = nema_motor_plinth_diam(size);
146 screw_spacing = nema_motor_screw_spacing(size);
147 screw_size = nema_motor_screw_size(size);
148 screw_depth = nema_motor_screw_depth(size);
149
150 orient_and_align([motor_width, motor_width, h], orient, align, orig_align=V_DOWN) {
151 difference() {
152 color([0.4, 0.4, 0.4])
153 cuboid(size=[motor_width, motor_width, h], chamfer=2, edges=EDGES_Z_ALL, align=V_DOWN);
154 color("silver")
155 xspread(screw_spacing)
156 yspread(screw_spacing)
157 cyl(r=screw_size/2, h=screw_depth*2, $fn=max(12,segs(screw_size/2)));
158 }
159 color([0.6, 0.6, 0.6]) {
160 difference() {
161 cylinder(h=plinth_height, d=plinth_diam);
162 cyl(h=plinth_height*3, d=shaft+0.75);
163 }
164 }
165 color("silver")
166 cylinder(h=shaft_len, d=shaft, $fn=max(12,segs(shaft/2)));
167 }
168}
169
170
171
172// Module: nema14_stepper()
173// Description: Creates a model of a NEMA 14 stepper motor.
174// Arguments:
175// h = Length of motor body. Default: 24mm
176// shaft = Shaft diameter. Default: 5mm
177// shaft_len = Length of shaft protruding out the top of the stepper motor. Default: 24mm
178// orient = Orientation of the stepper. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
179// align = Alignment of the stepper. Use the `V_` constants from `constants.scad`. Default: `V_DOWN`.
180// Example:
181// nema14_stepper();
182module nema14_stepper(h=24, shaft=5, shaft_len=24, orient=ORIENT_Z, align=V_DOWN)
183{
184 size = 14;
185 motor_width = nema_motor_width(size);
186 plinth_height = nema_motor_plinth_height(size);
187 plinth_diam = nema_motor_plinth_diam(size);
188 screw_spacing = nema_motor_screw_spacing(size);
189 screw_size = nema_motor_screw_size(size);
190 screw_depth = nema_motor_screw_depth(size);
191
192 orient_and_align([motor_width, motor_width, h], orient, align, orig_align=V_DOWN) {
193 difference() {
194 color([0.4, 0.4, 0.4])
195 cuboid(size=[motor_width, motor_width, h], chamfer=2, edges=EDGES_Z_ALL, align=V_DOWN);
196 color("silver")
197 xspread(screw_spacing)
198 yspread(screw_spacing)
199 cyl(d=screw_size, h=screw_depth*2, $fn=max(12,segs(screw_size/2)));
200 }
201 color([0.6, 0.6, 0.6]) {
202 difference() {
203 cylinder(h=plinth_height, d=plinth_diam);
204 cyl(h=plinth_height*3, d=shaft+0.75);
205 }
206 }
207 color("silver")
208 cyl(h=shaft_len, d=shaft, align=V_UP, $fn=max(12,segs(shaft/2)));
209 }
210}
211
212
213
214// Module: nema17_stepper()
215// Description: Creates a model of a NEMA 17 stepper motor.
216// Arguments:
217// h = Length of motor body. Default: 34mm
218// shaft = Shaft diameter. Default: 5mm
219// shaft_len = Length of shaft protruding out the top of the stepper motor. Default: 20mm
220// orient = Orientation of the stepper. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
221// align = Alignment of the stepper. Use the `V_` constants from `constants.scad`. Default: `V_DOWN`.
222// Example:
223// nema17_stepper();
224module nema17_stepper(h=34, shaft=5, shaft_len=20, orient=ORIENT_Z, align=V_DOWN)
225{
226 size = 17;
227 motor_width = nema_motor_width(size);
228 plinth_height = nema_motor_plinth_height(size);
229 plinth_diam = nema_motor_plinth_diam(size);
230 screw_spacing = nema_motor_screw_spacing(size);
231 screw_size = nema_motor_screw_size(size);
232 screw_depth = nema_motor_screw_depth(size);
233
234 orient_and_align([motor_width, motor_width, h], orient, align, orig_align=V_DOWN) {
235 difference() {
236 color([0.4, 0.4, 0.4])
237 cuboid([motor_width, motor_width, h], chamfer=2, edges=EDGES_Z_ALL, align=V_DOWN);
238 color("silver")
239 xspread(screw_spacing)
240 yspread(screw_spacing)
241 cyl(d=screw_size, h=screw_depth*2, $fn=max(12,segs(screw_size/2)));
242 }
243 color([0.6, 0.6, 0.6]) {
244 difference() {
245 cylinder(h=plinth_height, d=plinth_diam);
246 cyl(h=plinth_height*3, d=shaft+0.75);
247 }
248 }
249 color([0.9, 0.9, 0.9]) {
250 down(h-motor_width/12) {
251 fwd(motor_width/2+motor_width/24/2-0.1) {
252 difference() {
253 cube(size=[motor_width/8, motor_width/24, motor_width/8], center=true);
254 cyl(d=motor_width/8-2, h=motor_width/6, orient=ORIENT_Y, $fn=12);
255 }
256 }
257 }
258 }
259 color("silver") {
260 difference() {
261 cylinder(h=shaft_len, d=shaft, $fn=max(12,segs(shaft/2)));
262 up(shaft_len/2+1) {
263 right(shaft-0.75) {
264 cube([shaft, shaft, shaft_len], center=true);
265 }
266 }
267 }
268 }
269 }
270}
271
272
273
274// Module: nema23_stepper()
275// Description: Creates a model of a NEMA 23 stepper motor.
276// Arguments:
277// h = Length of motor body. Default: 50mm
278// shaft = Shaft diameter. Default: 6.35mm
279// shaft_len = Length of shaft protruding out the top of the stepper motor. Default: 25mm
280// orient = Orientation of the stepper. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
281// align = Alignment of the stepper. Use the `V_` constants from `constants.scad`. Default: `V_DOWN`.
282// Example:
283// nema23_stepper();
284module nema23_stepper(h=50, shaft=6.35, shaft_len=25, orient=ORIENT_Z, align=V_DOWN)
285{
286 size = 23;
287 motor_width = nema_motor_width(size);
288 plinth_height = nema_motor_plinth_height(size);
289 plinth_diam = nema_motor_plinth_diam(size);
290 screw_spacing = nema_motor_screw_spacing(size);
291 screw_size = nema_motor_screw_size(size);
292 screw_depth = nema_motor_screw_depth(size);
293
294 screw_inset = motor_width - screw_spacing + 1;
295 orient_and_align([motor_width, motor_width, h], orient, align, orig_align=V_DOWN) {
296 difference() {
297 union() {
298 color([0.4, 0.4, 0.4])
299 cuboid([motor_width, motor_width, h], chamfer=2, edges=EDGES_Z_ALL, align=V_DOWN);
300 color([0.4, 0.4, 0.4])
301 cylinder(h=plinth_height, d=plinth_diam);
302 color("silver")
303 cylinder(h=shaft_len, d=shaft, $fn=max(12,segs(shaft/2)));
304 }
305 color([0.4, 0.4, 0.4]) {
306 xspread(screw_spacing) {
307 yspread(screw_spacing) {
308 cyl(d=screw_size, h=screw_depth*3, $fn=max(12,segs(screw_size/2)));
309 down(screw_depth) cuboid([screw_inset, screw_inset, h], align=V_DOWN);
310 }
311 }
312 }
313 }
314 }
315}
316
317
318
319// Module: nema34_stepper()
320// Description: Creates a model of a NEMA 34 stepper motor.
321// Arguments:
322// h = Length of motor body. Default: 75mm
323// shaft = Shaft diameter. Default: 12.7mm
324// shaft_len = Length of shaft protruding out the top of the stepper motor. Default: 32mm
325// orient = Orientation of the stepper. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
326// align = Alignment of the stepper. Use the `V_` constants from `constants.scad`. Default: `V_DOWN`.
327// Example:
328// nema34_stepper();
329module nema34_stepper(h=75, shaft=12.7, shaft_len=32, orient=ORIENT_Z, align=V_DOWN)
330{
331 size = 34;
332 motor_width = nema_motor_width(size);
333 plinth_height = nema_motor_plinth_height(size);
334 plinth_diam = nema_motor_plinth_diam(size);
335 screw_spacing = nema_motor_screw_spacing(size);
336 screw_size = nema_motor_screw_size(size);
337 screw_depth = nema_motor_screw_depth(size);
338
339 screw_inset = motor_width - screw_spacing + 1;
340 orient_and_align([motor_width, motor_width, h], orient, align, orig_align=V_DOWN) {
341 difference() {
342 union() {
343 color([0.4, 0.4, 0.4])
344 cuboid(size=[motor_width, motor_width, h], chamfer=2, edges=EDGES_Z_ALL, align=V_DOWN);
345 color([0.4, 0.4, 0.4])
346 cylinder(h=plinth_height, d=plinth_diam);
347 color("silver")
348 cylinder(h=shaft_len, d=shaft, $fn=max(24,segs(shaft/2)));
349 }
350 color([0.4, 0.4, 0.4]) {
351 xspread(screw_spacing) {
352 yspread(screw_spacing) {
353 cylinder(d=screw_size, h=screw_depth*3, center=true, $fn=max(12,segs(screw_size/2)));
354 down(screw_depth) downcube([screw_inset, screw_inset, h]);
355 }
356 }
357 }
358 }
359 }
360}
361
362
363
364// Section: Masking Modules
365
366
367
368// Module: nema_mount_holes()
369// Description: Creates a mask to use when making standard NEMA stepper motor mounts.
370// Arguments:
371// size = The standard NEMA motor size to make a mount for.
372// depth = The thickness of the mounting hole mask. Default: 5
373// l = The length of the slots, for making an adjustable motor mount. Default: 5
374// slop = The printer-specific slop value to make parts fit just right. Default: `PRINTER_SLOP`
375// orient = Orientation of the stepper. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
376// align = Alignment of the stepper. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
377// Example:
378// nema_mount_holes(size=14, depth=5, l=5);
379// Example:
380// nema_mount_holes(size=17, depth=5, l=5);
381// Example:
382// nema_mount_holes(size=17, depth=5, l=0);
383module nema_mount_holes(size=17, depth=5, l=5, slop=PRINTER_SLOP, orient=ORIENT_Z, align=V_CENTER)
384{
385 motor_width = nema_motor_width(size);
386 plinth_diam = nema_motor_plinth_diam(size)+slop;
387 screw_spacing = nema_motor_screw_spacing(size);
388 screw_size = nema_motor_screw_size(size)+slop;
389
390 orient_and_align([motor_width, motor_width, l], orient, align) {
391 union() {
392 xspread(screw_spacing) {
393 yspread(screw_spacing) {
394 if (l>0) {
395 union() {
396 yspread(l) cyl(h=depth, d=screw_size, $fn=max(8,segs(screw_size/2)));
397 cube([screw_size, l, depth], center=true);
398 }
399 } else {
400 cyl(h=depth, d=screw_size, $fn=max(8,segs(screw_size/2)));
401 }
402 }
403 }
404 }
405 if (l>0) {
406 union () {
407 yspread(l) cyl(h=depth, d=plinth_diam);
408 cube([plinth_diam, l, depth], center=true);
409 }
410 } else {
411 cyl(h=depth, d=plinth_diam);
412 }
413 }
414}
415
416
417
418// Module: nema11_mount_holes()
419// Description: Creates a mask to use when making NEMA 11 stepper motor mounts.
420// Arguments:
421// depth = The thickness of the mounting hole mask. Default: 5
422// l = The length of the slots, for making an adjustable motor mount. Default: 5
423// slop = The printer-specific slop value to make parts fit just right. Default: `PRINTER_SLOP`
424// orient = Orientation of the stepper. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
425// align = Alignment of the stepper. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
426// Example:
427// nema11_mount_holes(depth=5, l=5);
428// Example:
429// nema11_mount_holes(depth=5, l=0);
430module nema11_mount_holes(depth=5, l=5, slop=PRINTER_SLOP, orient=ORIENT_Z, align=V_CENTER)
431{
432 nema_mount_holes(size=11, depth=depth, l=l, slop=slop, orient=orient, align=align);
433}
434
435
436
437// Module: nema14_mount_holes()
438// Description: Creates a mask to use when making NEMA 14 stepper motor mounts.
439// Arguments:
440// depth = The thickness of the mounting hole mask. Default: 5
441// l = The length of the slots, for making an adjustable motor mount. Default: 5
442// slop = The printer-specific slop value to make parts fit just right. Default: `PRINTER_SLOP`
443// orient = Orientation of the stepper. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
444// align = Alignment of the stepper. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
445// Example:
446// nema14_mount_holes(depth=5, l=5);
447// Example:
448// nema14_mount_holes(depth=5, l=0);
449module nema14_mount_holes(depth=5, l=5, slop=PRINTER_SLOP, orient=ORIENT_Z, align=V_CENTER)
450{
451 nema_mount_holes(size=14, depth=depth, l=l, slop=slop, orient=orient, align=align);
452}
453
454
455
456// Module: nema17_mount_holes()
457// Description: Creates a mask to use when making NEMA 17 stepper motor mounts.
458// Arguments:
459// depth = The thickness of the mounting hole mask. Default: 5
460// l = The length of the slots, for making an adjustable motor mount. Default: 5
461// slop = The printer-specific slop value to make parts fit just right. Default: `PRINTER_SLOP`
462// orient = Orientation of the stepper. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
463// align = Alignment of the stepper. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
464// Example:
465// nema17_mount_holes(depth=5, l=5);
466// Example:
467// nema17_mount_holes(depth=5, l=0);
468module nema17_mount_holes(depth=5, l=5, slop=PRINTER_SLOP, orient=ORIENT_Z, align=V_CENTER)
469{
470 nema_mount_holes(size=17, depth=depth, l=l, slop=slop, orient=orient, align=align);
471}
472
473
474
475// Module: nema23_mount_holes()
476// Description: Creates a mask to use when making NEMA 23 stepper motor mounts.
477// Arguments:
478// depth = The thickness of the mounting hole mask. Default: 5
479// l = The length of the slots, for making an adjustable motor mount. Default: 5
480// slop = The printer-specific slop value to make parts fit just right. Default: `PRINTER_SLOP`
481// orient = Orientation of the stepper. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
482// align = Alignment of the stepper. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
483// Example:
484// nema23_mount_holes(depth=5, l=5);
485// Example:
486// nema23_mount_holes(depth=5, l=0);
487module nema23_mount_holes(depth=5, l=5, slop=PRINTER_SLOP, orient=ORIENT_Z, align=V_CENTER)
488{
489 nema_mount_holes(size=23, depth=depth, l=l, slop=slop, orient=orient, align=align);
490}
491
492
493
494// Module: nema34_mount_holes()
495// Description: Creates a mask to use when making NEMA 34 stepper motor mounts.
496// Arguments:
497// depth = The thickness of the mounting hole mask. Default: 5
498// l = The length of the slots, for making an adjustable motor mount. Default: 5
499// slop = The printer-specific slop value to make parts fit just right. Default: `PRINTER_SLOP`
500// orient = Orientation of the stepper. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
501// align = Alignment of the stepper. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
502// Example:
503// nema34_mount_holes(depth=5, l=5);
504// Example:
505// nema34_mount_holes(depth=5, l=0);
506module nema34_mount_holes(depth=5, l=5, slop=PRINTER_SLOP, orient=ORIENT_Z, align=V_CENTER)
507{
508 nema_mount_holes(size=34, depth=depth, l=l, slop=slop, orient=orient, align=align);
509}
510
511
512
513// Module: nema34_mount_holes()
514// Description: Creates a mask to use when making NEMA 34 stepper motor mounts.
515// Arguments:
516// depth = The thickness of the mounting hole mask. Default: 5
517// l = The length of the slots, for making an adjustable motor mount. Default: 5
518// slop = The printer-specific slop value to make parts fit just right. Default: `PRINTER_SLOP`
519// orient = Orientation of the stepper. Use the `ORIENT_` constants from `constants.scad`. Default: `ORIENT_Z`.
520// align = Alignment of the stepper. Use the `V_` constants from `constants.scad`. Default: `V_CENTER`.
521// Example:
522// nema34_mount_holes(depth=5, l=5);
523// Example:
524// nema34_mount_holes(depth=5, l=0);
525module nema34_mount_holes(depth=5, l=5, slop=PRINTER_SLOP, orient=ORIENT_Z, align=V_CENTER)
526{
527 nema_mount_holes(size=34, depth=depth, l=l, slop=slop, orient=orient, align=align);
528}
529
530
531
532// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap